﻿// ************************************************************************************************
// serialization..
function $get(el) { 
    return document.getElementById(el);
}
// ************************************************************************************************

var createGenericHandler = function (handler) { 
  return function(e) {
    if (!e) e=window.event;
    if (e) e.cancelBubble = true;
    var ce = CreateObject(new CancelEventArgs(), [false]); // TODO: namespace
    handler.invoke(this, ce);
    if (e) e.returnValue = !ce.get_Canceled();
    return !ce.get_Canceled();
  };
}

var createMouseHandler = function (handler) { 
  return function(e) {
    if (!e) e=window.event;
    var pos = new Position(); // TODO: namespace
  	if (e.pageX || e.pageY) {
  		pos.set_Left(e.pageX);
      pos.set_Top(e.pageY);
    } else if (e.clientX || e.clientY) 	{
  		pos.set_Left(e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft);
      pos.set_Top(e.clientY + document.body.scrollTop + document.documentElement.scrollTop);
  	}
  	var ce = new MouseEventArgs(); ce.ctor(e.button, pos); // TODO: namespace
    handler.invoke(this, ce);
    if (e) e.returnValue = !ce.get_Canceled();
    return !ce.get_Canceled();
  };
}


function createEvent() {
  return new function() {
    this.handlers = new Array();
    this.add = function(o) { this.handlers.push(o); }
    this.remove = function(o) { var i = this.handlers.indexOf(o); if (i != -1) this.handlers.removeAt(i); }
    this.invoke = function(sender,e) { 
      for (var i = 0; i<this.handlers.length; i++) 
        this.handlers[i](sender,e);
    }
  }
}

function attachHandler(el, name, func)
{
  if (el.addEventListener)
    el.addEventListener(name, func, true)
  else
    el.attachEvent("on" + name, func);        
}

// ************************************************************************************************

Type.registerNamespace("Lib");

Lib.Utils = new Object();
Lib.Convert = new Object();

// JS primitive language constructs & ugly dynamic tricks
Lib.Utils.TryCatch = function(f,h) { try { 
    return f(); 
  } catch(e) { return h(); } }
Lib.Utils.Not = function(o) { return !o; }
Lib.Utils.Cast = function(o) { return o; }
Lib.Utils.Subtract = function(a,b) { return a-b; }
Lib.Utils.FailWith = function(o) { /*alert("DEBUG: throwing exception: "+o); */ throw o; }
Lib.Utils.Ignore = function(o) { }
Lib.Utils.GetMember = function(o, m) { return eval("o." + m); }
Lib.Utils.SetMember = function(o, m, v) { eval("o." + m + " = v;"); }
Lib.Utils.InvokeMember = function(o, m, args) { return eval("o." + m + ".apply(o, args)"); }
Lib.Utils.InvokeStatic = function(m, args) { return eval(m + ".apply(null, args)"); }
Lib.Utils.HasValue = function(o) { if (o!=null) return true; else return false; }
Lib.Utils.MembersIter = function(o, f) { for(var v in o) { f(v); }; }
Lib.Utils.StrLength = function(s) { return s.length; }
Lib.Utils.ArrayZeroCreate = function(n, ty) { var arr = new Array(); for(var i=0; i<n; i++) arr[i]=null; return CreateArray(arr, ty); }
Lib.Utils.OpIndexedAssign = function(col, i, v) { if (col.set_Item) col.set_Item(i,v); else col[i]=v; }
Lib.Utils.OpIndexedLookup = function(col, i, v) { if (col.get_Item) return col.get_Item(i); else return col[i]; }
Lib.Utils.GetArguments = function(args) { var ret = new Array(); for(var i=0; i<args.length; i++) ret.push(args[i]); return ret; } // it's not a real array for some reason
Lib.Convert.ToString = function(o) { if (o && o.ToString) return o.ToString(); else return ""+o; }
Lib.Convert.ToFloat  = function(o) { return o*1.0; }
Lib.Convert.ToInt    = function(o) { return o*1; }

Array.prototype.get_Item = function(i) { if (i>=this.length) Lib.Utils.FailWith("Index out of range!"); return this[i]; }
Array.prototype.set_Item = function(i, v) { if (i>=this.length) Lib.Utils.FailWith("Index out of range!"); this[i] = v; }
Array.prototype.removeAt = function(i) { this.splice(i,1); }
Array.prototype.indexOf = function(v) { for(var i=0; i<this.length; i++) { if (v == this[i]) return i; } return -1; }

String.prototype.startsWith = function(s) { return this.indexOf(s) == 0; }
String.prototype.toCharArray = function() { return this.split(""); }
String.prototype.replaceAll = function(s,rep) { 
  var res = "";
  var tmp = this; 
  var idx = 0;
  while((idx = tmp.indexOf(s)) != -1)
  {
    res = res + tmp.substr(0, idx) + rep;
    tmp = tmp.substr(idx+s.length);
  }
  return res + tmp; 
}

// ************************************************************************************************

var prevOnLoad = window.onload;
var loaded = false;
var initialized = false;
var thisPage = null;

window.onload = function(e) { 
  if (prevOnLoad!=null) prevOnLoad(e); 
  loaded = true;
  if (deserializePageState) deserializePageState();
  thisPage.OnClientLoad();
};

function CreateArray(arr, ty) 
{
  arr.__js_special__ = "array";
  arr.__net_type__ = ty;
  return arr;
}

function CreateRecord(rec, ty) 
{
  rec.__js_special__ = "record";
  rec.__net_type__ = ty;
  return rec;
}

function CreatePage(el, args)
{
  el.ctor.apply(el, args);
  initialized = true;
  el.OnClientInit();
  return el;
}

function CreateObject(el, args)
{
  el.ctor.apply(el, args);
  return el;
}

var wraperCache = new Array();

function CreateElement(el, args)
{
  el.ctor.apply(el, args);
  wraperCache[el.id] = el;
  return el;
}

function DropWrapper(id)
{
  wraperCache[id] = null;
}

function getAndWrapOption(ddl,i)
{
  return CreateElement(new Dom.Element(), [ddl.el.item(i)]);
}

function clearAllOptions(ddl)
{
  while(ddl.el.length != 0)
    ddl.el.remove(0);
}

function createAndAddOption(ddl)
{
  var el = document.createElement("OPTION")
  ddl.el.add(el)
  return CreateElement(new Dom.Element(), [el]);
}

function WrapElement(el)
{
  if (!wraperCache[el.id]) 
  { 
    var wel = CreateElement(new Dom.Element(), [el]); 
    wraperCache[el.id] = wel;
    wel.OnClientInit();
    wel.OnClientLoad();
  }
  return (wraperCache[el.id]);
}

// ************************************************************************************************
// TODO: all these types should be written in F#, it is legacy code...

Type.registerNamespace("Dom");

Dom.Page = function() { 
    this.Controls = null;
    this.mouseDown = null;
    this.mouseUp = null;
    this.mouseMove = null;
    this.serverId = "thisPage"; // this is used by serializer
    this.id = "thisPage";
}
Dom.Page.prototype = {
    ctor : function() {
        this.Controls = CreateObject(new ResizeArray(), []);
        this.mouseDown = createEvent();
        this.mouseUp = createEvent();
        this.mouseMove = createEvent();
    },
    OnClientInitControls : function() {
    },
    OnClientInit : function() {
      attachHandler(document.body, 'mousedown', Function.createDelegate(this, createMouseHandler(this.mouseDown) ));
      attachHandler(document.body, 'mouseup', Function.createDelegate(this, createMouseHandler(this.mouseUp) ));
      attachHandler(document.body, 'mousemove', Function.createDelegate(this, createMouseHandler(this.mouseMove) ));
      
      this.OnClientInitControls();
      for(var i=0; i<this.Controls.get_Count(); i++)
        this.Controls.get_Item(i).OnClientInit();
    },
    OnClientLoad : function() { 
      for(var i=0; i<this.Controls.get_Count(); i++)
        this.Controls.get_Item(i).OnClientLoad();
      if (this.Client_Load) 
        this.Client_Load();
    },
    FindControl : function(id) {  
      for(var i=0; i<this.Controls.get_Count(); i++)
      {
        var c = this.Controls.get_Item(i)
        if (c.id == id) return c;
      }
      throw "Couln't find '"+id+"'!";
    },
    get_size : function() {
      var ret = new Object();
      var test = document.body.scrollHeight > document.body.offsetHeight;
      ret.width = test?document.body.scrollWidth:document.body.offsetWidth;
      ret.height = test?document.body.scrollHeight:document.body.offsetHeight;
      return ret;
    },    
    get_viewRect : function() {
      var rc = new Object();
      rc.left = document.documentElement.scrollLeft;
      rc.top = document.documentElement.scrollTop;
      rc.height = document.documentElement.clientHeight;
      rc.width = document.documentElement.clientWidth;
      return rc;
    },
    get_ClientMouseDown : function() { return this.mouseDown; },
    get_ClientMouseUp : function() { return this.mouseUp; },
    get_ClientMouseMove : function() { return this.mouseMove; },
    
    get_ID : function() { return this.serverId; },
    set_ID : function(val) { this.serverId=val; },
    get_ClientID : function() { return this.id; }
};
Dom.Page.registerClass('Dom.Page');

// ************************************************************************************************

Dom.Element = function()
{
    this.__mixed_fields__ = [];
    this.__js_class__ = "native:System.Web.UI.Control, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
    Dom.Element.initializeBase(this);
    this.Controls = null;
    this.el = null;
    this.id = null;
    this.serverId = null;
    this.mouseDown = null;
    this.mouseUp = null;
    this.mouseMove = null;
    this.selectStart = null;
    this.click = null;
}    
Dom.Element.prototype = {          
    ctor : function(el) {
        this.Controls = CreateObject(new ResizeArray(), []);
        this.el = el;
        this.id = el.id;
        this.serverId = "";
        this.mouseDown = createEvent();
        this.mouseUp = createEvent();
        this.mouseMove = createEvent();
        this.selectStart = createEvent();    
        this.click = createEvent();
    },
    OnClientInitControls : function() {
    },
    AttachHandler : function(name, func) {
      attachHandler(this.el, name, func);
    },
    OnClientInit : function() {
      attachHandler(this.el, 'mousedown', Function.createDelegate(this, createMouseHandler(this.mouseDown) ));
      attachHandler(this.el, 'mouseup', Function.createDelegate(this, createMouseHandler(this.mouseUp) ));
      attachHandler(this.el, 'mousemove', Function.createDelegate(this, createMouseHandler(this.mouseMove) ));
      attachHandler(this.el, 'selectstart', Function.createDelegate(this, createGenericHandler(this.selectStart) ));
      attachHandler(this.el, 'click', Function.createDelegate(this, createGenericHandler(this.click) ));
      
      this.OnClientInitControls();
      for(var i=0; i<this.Controls.get_Count(); i++)
        this.Controls.get_Item(i).OnClientInit();
    },
    FindControl : function(id) {  
      for(var i=0; i<this.Controls.get_Count(); i++)
      {
        var c = this.Controls.get_Item(i)
        if (c.id == id) return c;
      }
      throw "Couln't find '"+id+"'!";
    },
    OnClientLoad : function() { 
      for(var i=0; i<this.Controls.get_Count(); i++)
        this.Controls.get_Item(i).OnClientLoad();
      this.Client_Load();
    },
    Client_Load : function() {
      // ni
    },
    set_Size : function(size) {
      this.el.style.width = size.width+'px';
      this.el.style.height = size.height+'px';
    },
    set_Position : function(pos) {
      this.el.style.left = pos.left+'px';
      this.el.style.top = pos.top+'px';
    },
    get_Position : function() {
      var pos = new Object();
      var parent = this.el;
      pos.left = this.el.offsetLeft; pos.top = this.el.offsetTop;
      while(parent = parent.offsetParent)
      {
        pos.left += parent.offsetLeft; 
        pos.top += parent.offsetTop;
      }
      return pos;
    },    
    set_Visible : function(val) {
      this.el.style.visibility=val?'visible':'hidden';
    },
    get_Visible : function(val) {
      return this.el.style.visibility=='visible';
    },
    
    // WORKAROUND: for the 'convMethodRef' bug in F# 1.9.3 - added following two duplicates (to be removed)
    set_ClientVisible : function(val) {
      this.set_Visible(val);
    },
    get_ClientVisible : function(val) {
      return this.get_Visible();
    },
    
    SetupDragDrop : function(target) {
      var dist = new Object();
      //var ss = thisPage.SelectStart;
      //var win = new Dom.Page();
      //win.init();
      
      var cancelSel = function(sender, e) {
        event.returnValue = false;
      }
      var mouseMove = function(sender, e) { 
        var pos = new Position(); // TODO: namespace
        pos.left = e.get_Position().left - dist.width;
        pos.top = e.get_Position().top - dist.height;
        target.set_Position(pos);
      }
      var mouseUp = function(sender, e) { 
        thisPage.get_ClientMouseMove().remove(mouseMove);
        thisPage.get_ClientMouseUp().remove(mouseUp);
        //ss.remove(cancelSel);
      }
      this.get_ClientMouseDown().add(function(sender, e) { 
        var tp = target.get_Position();
        var cp = e.get_Position();
        dist.width = cp.left - tp.left;
        dist.height = cp.top - tp.top;
        thisPage.get_ClientMouseMove().add(mouseMove);
        thisPage.get_ClientMouseUp().add(mouseUp);
        //ss.add(cancelSel);
      });
    },
    GetChild : function(id) {
      function getElChild(el, id) {
        if (!el||!el.tagName||!el.childNodes) return null;
        if (el.id == id) return el;
        
        for(var i=0; i<el.childNodes.length; i++) {
          var sub = el.childNodes[i];
          var subRet = getElChild(sub, id);
          if (subRet) return subRet;
        }
      }
      var e = getElChild(this.el, this.id+"_"+id);
      if (e)
        return CreateObject(new DiscriminatedUnion(), ["Some", [WrapElement(e)]]);
      else
        return CreateObject(new DiscriminatedUnion(), ["None", []]);
    },
    DestroyChildren : function() {
      function destroyChildren(el) {
        if (!el||!el.tagName||!el.childNodes) return;
        DropWrapper(el.id);
        for(var i=0; i<el.childNodes.length; i++) {
          var sub = el.childNodes[i];
          destroyChildren(sub);
        }
      }
      destroyChildren(this.el);
    },    
    AppendChild : function(obj) {
      this.el.appendChild(obj.el);
    },
    AddCssClass : function(cls) {
      this.el.className = this.el.className + " " + cls;
    },
    RemoveCssClass : function(cls) {
      var sp = this.el.className.split(" ");
      var res = "";
      cls = cls.replaceAll(" ", "");
      for(var i=0; i<sp.length; i++)
      {
        var cn = sp[i].replaceAll(" ", "");
        if (cn != cls) res = res + " " + cn;
      }
      this.el.className = res;
    },
    
    get_ClientMouseDown : function()    { return this.mouseDown; },
    get_ClientMouseUp : function()      { return this.mouseUp; },
    get_ClientMouseMove : function()    { return this.mouseMove; },
    get_ClientSelectStart : function()  { return this.selectStart; },
    get_ClientClick : function()        { return this.click; },
    
    get_Value     : function()    { return this.el.value; },
    set_Value     : function(val) { this.el.value = val; },
    get_InnerHtml : function()    { return this.el.innerHTML; },
    set_InnerHtml : function(val) { this.DestroyChildren(); this.el.innerHTML = val; },
    get_InnerText : function()    { return this.el.innerText; },
    set_InnerText : function(val) { this.el.innerText = val; },
    
    get_ID : function() { return this.serverId; },
    set_ID : function(val) { this.serverId=val; },
    get_ClientID : function() { return this.id; }
}
Dom.Element.registerClass('Dom.Element');

// ************************************************************************************************

Dom.Label = function() { 
    this.__mixed_fields__ = [];
    this.__js_class__ = "native:System.Web.UI.WebControls.Label, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";;
    Dom.Label.initializeBase(this);
}
Dom.Label.prototype = {
    ctor : function(el) {
        Dom.Label.callBaseMethod(this, "ctor", [el]);
    },
    get_Text : function() {
      return this.el.innerHTML;
    },
    set_Text : function(val) {
      this.el.innerHTML = val;
    },

    // WORKAROUND: for the 'convMethodRef' bug in F# 1.9.3 - added following two duplicates (to be removed)
    get_ClientText : function() {
      return this.get_Text();
    },
    set_ClientText : function(val) {
      this.set_Text(val);
    }
};
Dom.Label.registerClass('Dom.Label', Dom.Element);

Dom.Button = function() {
    this.__mixed_fields__ = [];
    this.__js_class__ = "native:System.Web.UI.WebControls.Button, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
    Dom.Button.initializeBase(this);
}
Dom.Button.prototype = {
    ctor : function(el) {
        Dom.Button.callBaseMethod(this, "ctor", [el]);
    },
    get_Text : function() {
      return this.el.innerHTML;
    },
    set_Text : function(val) {
      this.el.innerHTML = val;
    },

    // WORKAROUND: for the 'convMethodRef' bug in F# 1.9.3 - added following two duplicates (to be removed)
    get_ClientText : function() {
      return this.get_Text();
    },
    set_ClientText : function(val) {
      this.set_Text(val);
    }
};
Dom.Button.registerClass('Dom.Button', Dom.Element);

Dom.TextBox = function() {
    this.__mixed_fields__ = [];
    this.__js_class__ = "native:System.Web.UI.WebControls.TextBox, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
    Dom.TextBox.initializeBase(this);
    this.textchanged = null;
    this.keyup = null;
    this.keydown = null;
    this.keypress = null;
}
Dom.TextBox.prototype = {
    ctor : function(el) {
        Dom.TextBox.callBaseMethod(this, "ctor", [el]);
        this.textchanged = createEvent();
        this.keyup = createEvent();
        this.keydown = createEvent();
        this.keypress = createEvent();        
        attachHandler(this.el, 'change', Function.createDelegate(this, createGenericHandler(this.textchanged) ));
        attachHandler(this.el, 'keyup', Function.createDelegate(this, createGenericHandler(this.keyup) ));
        attachHandler(this.el, 'keydown', Function.createDelegate(this, createGenericHandler(this.keydown) ));
        attachHandler(this.el, 'keypress', Function.createDelegate(this, createGenericHandler(this.keypress) ));
    },
    get_Text : function() {
      return this.el.value;
    },
    set_Text : function(val) {
      this.el.value = val;
    },
    
    // WORKAROUND: for the 'convMethodRef' bug in F# 1.9.3 - added following two duplicates (to be removed)
    get_ClientText : function() {
      return this.get_Text();
    },
    set_ClientText : function(val) {
      this.set_Text(val);
    },
    
    get_ClientTextChanged : function() { return this.textchanged; },
    get_ClientKeyUp : function() { return this.keyup; },
    get_ClientKeyDown : function() { return this.keydown; },
    get_ClientKeyPress : function() { return this.keypress; }
};
Dom.TextBox.registerClass('Dom.TextBox', Dom.Element);

Dom.DropDownList = function() {
    this.__mixed_fields__ = [];
    this.__js_class__ = "native:System.Web.UI.WebControls.DropDownList, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";;;
    Dom.DropDownList.initializeBase(this);
    this.selectionchanged = null;
}
Dom.DropDownList.prototype = {
    ctor : function(el) {
        Dom.DropDownList.callBaseMethod(this, "ctor", [el]);
        this.selectionchanged = createEvent();
        attachHandler(this.el, 'change', Function.createDelegate(this, createGenericHandler(this.selectionchanged) ));
    },
    get_SelectedKey : function() {
      return this.el.value;
    },
    set_SelectedKey : function(val) {
      alert('not supported!'); this.el.value = val;
    },
    get_SelectedValue : function() {
      alert('not supported!'); return alert(this.el.value);
    },
    set_SelectedValue : function(val) {
      alert('not supported!'); this.el.value = val;
    },
    get_ClientSelectionChanged : function() { return this.selectionchanged; }
};
Dom.DropDownList.registerClass('Dom.DropDownList', Dom.Element);

Dom.RadioButton = function() {
    this.__mixed_fields__ = [];
    this.__js_class__ = "native:System.Web.UI.WebControls.RadioButton, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";;
    Dom.RadioButton.initializeBase(this);
}
Dom.RadioButton.prototype = {
    ctor : function(el) {
        Dom.RadioButton.callBaseMethod(this, "ctor", [el]);
    },
    get_Checked : function() {
      return this.el.checked;
    },
    set_Checked : function(val) {
      this.el.checked = val;
    },
    get_ClientCheckedChanged : function() { return this.get_ClientClick(); }
};
Dom.RadioButton.registerClass('Dom.RadioButton', Dom.Element);



Dom.HyperLink = function() {
    this.__mixed_fields__ = [];
    this.__js_class__ = "native:System.Web.UI.WebControls.HyperLink, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
    Dom.HyperLink.initializeBase(this);
    this.nclick = null;
}
Dom.HyperLink.prototype = {
    ctor : function(el) {
        this.nclick = createEvent();
        Dom.HyperLink.callBaseMethod(this, "ctor", [el]);
        
        var ce = Dom.HyperLink.callBaseMethod(this, "get_ClientClick", []);
        ce.add(Function.createDelegate(this, function (s, e) {
            if (this.get_Enabled()) 
              this.nclick.invoke(s, e);
            else
              e.set_Canceled(true);
          }));
    },
    get_Text : function() {
      return this.el.innerHTML;
    },
    set_Text : function(val) {
      this.el.innerHTML = val;
    },

    // WORKAROUND: for the 'convMethodRef' bug in F# 1.9.3 - added following two duplicates (to be removed)
    get_ClientText : function() {
      return this.get_Text();
    },
    set_ClientText : function(val) {
      this.set_Text(val);
    },

    get_Enabled : function() {
      return !this.el.disabled;
    },
    set_Enabled : function(val) {
      this.el.disabled = !val;
    },
    get_NavigateUrl : function() {
      return this.el.href;
    },
    set_NavigateUrl : function(val) {
      this.el.href = val;
    },
    get_ClientClick : function() { return this.nclick; }    
};
Dom.HyperLink.registerClass('Dom.HyperLink', Dom.Element);

Dom.Image = function() {
    this.__mixed_fields__ = [];
    this.__js_class__ = "native:System.Web.UI.WebControls.Image, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
    Dom.Image.initializeBase(this);
}
Dom.Image.prototype = {
    ctor : function(el) {
        Dom.Image.callBaseMethod(this, "ctor", [el]);
    },
    get_ImageUrl : function() {
      return this.el.src;
    },
    set_ImageUrl : function(val) {
      this.el.src = val;
    },
    
    // WORKAROUND: for the 'convMethodRef' bug in F# 1.9.3 - added following two duplicates (to be removed)
    get_ClientImageUrl : function() {
      return this.get_ImageUrl();
    },
    set_ClientImageUrl : function(val) {
      this.set_ImageUrl(val);
    }
};
Dom.Image.registerClass('Dom.Image', Dom.Element);

Dom.LinkButton = function() {
    this.__mixed_fields__ = [];
    this.__js_class__ = "native:System.Web.UI.WebControls.LinkButton, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
    Dom.LinkButton.initializeBase(this);
    this.nclick = null;
}
Dom.LinkButton.prototype = {
    ctor : function(el) {
        this.nclick = createEvent();
        Dom.LinkButton.callBaseMethod(this, "ctor", [el]);
        
        var ce = Dom.LinkButton.callBaseMethod(this, "get_ClientClick", []);
        ce.add(Function.createDelegate(this, function (s, e) {
            if (this.get_Enabled()) 
              this.nclick.invoke(s, e);
            else
              e.set_Canceled(true);
          }));
    },
    get_Text : function() {
      return this.el.innerHTML;
    },
    set_Text : function(val) {
      this.el.innerHTML = val;
    },


    // WORKAROUND: for the 'convMethodRef' bug in F# 1.9.3 - added following two duplicates (to be removed)
    get_ClientText : function() {
      return this.get_Text();
    },
    set_ClientText : function(val) {
      this.set_Text(val);
    },
    
    get_Enabled : function() {
      return !this.el.disabled;
    },
    set_Enabled : function(val) {
      this.el.disabled = !val;
    },
    get_ClientClick : function() { return this.nclick; }
};
Dom.LinkButton.registerClass('Dom.LinkButton', Dom.Element);